/**
 * createby : JinxLbj
 * date : 2018/9/26
 * desc :
 **/

package jinx.lbj.springcloud_ribbon.service.impl;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import jinx.lbj.springcloud_ribbon.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class HelloServiceImpl implements HelloService{

    @Autowired
    RestTemplate restTemplate;

    @Override
    @HystrixCommand(fallbackMethod = "hiError")
    public String hiServer(String name) {
        return restTemplate.getForObject("http://SPRINGCLOUD-MODEL/hi?name=" + name, String.class);
    }

    public String hiError(String name){
        return "hi,"+name+",sorry,error!";
    }
}
